package com.aishua.fire.common;

import java.util.List;

/**
 * Created by zhouwei on 2018/8/23.
 */
public class JsonArrayResult<T> {

    private int code;
    private String message;
    private List<T> data; // 本次分页数据数组
    private int total;  // 条件查询总数

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }
    
    public static <T> JsonArrayResult<T> makeSuccessResult(List<T> data,int total) {
    	JsonArrayResult<T> result = new JsonArrayResult<>();
        result.setCode(0);
        result.setMessage("success");
        result.setData(data);
        result.setTotal(total);
        return result;
    }
    
    public static <T> JsonArrayResult<T> makeErrorResult(List<T> data) {
    	JsonArrayResult<T> result = new JsonArrayResult<>();
        result.setCode(1);
        result.setMessage("fail");
        result.setData(data);
        return result;
    }
    
}
